<?php

namespace App\Exports;

use Maatwebsite\Excel\Concerns\WithMultipleSheets;
use Maatwebsite\Excel\Concerns\Exportable;


class ClaseExport implements WithMultipleSheets
{

    use Exportable;

    private $tid;

    public function __construct(int $tid)        // 导入外部查询参数
    {
        $this->tid = $tid;
    }


    public function sheets(): array
    {
        $sheets = [];

        $clases = \App\Models\Edu\Clase::with('term','users','users.info')
                ->where('term_id', $this->tid)
                ->orderBy('id', 'desc')
                ->get();
                //dd($clases);
        foreach($clases as $clase) {

            $sheets[] = new \App\Exports\ClaseSheet($clase);
        }

        return $sheets;
    }

}
